package cc.rengu.igas.route.core.realize.credit.asyncdeal;


import cc.rengu.igas.route.common.constant.SmartRouteParamConstant;
import cc.rengu.oltp.service.base.DubboAsynBaseService;
import cc.rengu.oltp.service.common.constant.TreeNodeConstant;
import cc.rengu.oltp.service.common.entity.PayOrderInfo;
import cc.rengu.oltp.service.common.enums.BizStatusEnum;
import cc.rengu.oltp.service.common.enums.OltpRpcdEnum;
import cc.rengu.oltp.service.common.enums.TransStatusEnum;
import cc.rengu.oltp.service.model.BizException;
import cc.rengu.oltp.service.realize.OrderService;
import cc.rengu.oltp.service.realize.impl.OrderServiceImpl;
import cc.rengu.oltp.utility.annotation.BIZ_PROCESS;
import cc.rengu.oltp.utility.util.DateUtil;
import cc.rengu.oltp.utility.util.XmlTreeUtil;
import com.alibaba.fastjson.JSONObject;

/**
 * TODO 营销合并支付异步撤销
 */
public class DealAsyncUpacCoreWithHoldingPayService extends DubboAsynBaseService {
    @BIZ_PROCESS
    public void dealAsyncUpacCoreWithHoldingPayService() throws Exception {
        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        OrderService orderService = new OrderServiceImpl();

        rglog.info("xmlTree = <{}>", xmlTreeUtil.toString());
        PayOrderInfo payOrderInfo = (PayOrderInfo) xmlTreeUtil.getXmlTreeObjectValue(SmartRouteParamConstant.WITH_HOLDING_PAY_ORDER_INFO, PayOrderInfo.class);
        if (null == payOrderInfo) {
            rglog.info("获取预扣款支付订单信息异常");
            throw new BizException(OltpRpcdEnum.RECOND_EMPTY_OR_NOT_FOUND.getRespCode(), OltpRpcdEnum.RECOND_EMPTY_OR_NOT_FOUND.getRespDesc());
        }
        rglog.info("获取到原支付订单 ,payOrderInfo = <{}>", JSONObject.toJSONString(payOrderInfo));
        //TODO  step1、核心-通用冲正  由项目组实现该交易

//        /* step2、判断冲正结果，更新状态*/

        rglog.info("赋值完成");
        if (orderService.updateOrderInfo(null, null, payOrderInfo)) {
            rglog.info("更新银联全渠道预扣款支付订单信息成功");
        } else {
            rglog.error("更新银联全渠道预扣款支付订单信息失败");
        }
        rglog.info("更新成功");
    }
}
